1 //+-----------------------------------------------------------------------
3 // Copyright (c) Microsoft Corporation. All rights reserved.
6 // Implements the OleInPlaceActiveObject class of PresentationHost.
12 // Ported Windows->DevDiv. See SourcesHistory.txt.
14 //------------------------------------------------------------------------
16 #include "Precompiled.hxx"
17 #include "OleInPlaceActiveObject.hxx"
18 #include "OleDocument.hxx"
19 #include "Utilities.hxx"
21 //******************************************************************************
23 // COleInPlaceActiveObject::COleInPlaceActiveObject()
25 //******************************************************************************
27 COleInPlaceActiveObject::COleInPlaceActiveObject(__in COleDocument
*pOleDoc
)
30 //m_fEnableModeless = FALSE;
32 //******************************************************************************
34 // COleInPlaceActiveObject::~COleInPlaceActiveObject()
36 //******************************************************************************
38 COleInPlaceActiveObject::~COleInPlaceActiveObject()
42 //******************************************************************************
44 // COleInPlaceActiveObject::QueryInterface()
46 //******************************************************************************
48 STDMETHODIMP
COleInPlaceActiveObject::QueryInterface(REFIID riid
,
49 __out LPVOID
*ppReturn
)
51 // IE queries for IInputObject via CHostShim.
53 return m_pOleDoc
->QueryInterface(riid
, ppReturn
);
56 //******************************************************************************
58 // COleInPlaceActiveObject::AddRef()
60 //******************************************************************************
62 STDMETHODIMP_(ULONG
) COleInPlaceActiveObject::AddRef()
64 return m_pOleDoc
->AddRef();
67 //******************************************************************************
69 // COleInPlaceActiveObject::Release()
71 //******************************************************************************
73 STDMETHODIMP_(ULONG
) COleInPlaceActiveObject::Release()
75 return m_pOleDoc
->Release();
78 //******************************************************************************
80 // COleInPlaceActiveObject::OnDocWindowActivate()
82 //******************************************************************************
84 STDMETHODIMP
COleInPlaceActiveObject::OnDocWindowActivate(BOOL fActivate
)
89 //******************************************************************************
91 // COleInPlaceActiveObject::OnFrameWindowActivate()
93 //******************************************************************************
95 STDMETHODIMP
COleInPlaceActiveObject::OnFrameWindowActivate(BOOL fActivate
)
97 IBrowserHostServices
*pBrowserHost
;
99 pBrowserHost
= m_pOleDoc
->ApplicationHelper();
101 if ( pBrowserHost
!= NULL
)
103 pBrowserHost
->Activate(fActivate
);
109 //******************************************************************************
111 // COleInPlaceActiveObject::GetWindow()
113 //******************************************************************************
115 STDMETHODIMP
COleInPlaceActiveObject::GetWindow(__out HWND
*phwnd
)
117 return m_pOleDoc
->GetWindow(phwnd
);
120 //******************************************************************************
122 // COleInPlaceActiveObject::ContextSensitiveHelp()
124 //******************************************************************************
126 STDMETHODIMP
COleInPlaceActiveObject::ContextSensitiveHelp(BOOL
/* fEnterMode */)
131 //******************************************************************************
132 // COleInPlaceActiveObject::TranslateAccelerator()
133 // We would look up our own accelerators here, but we don't have any.
134 //******************************************************************************
136 STDMETHODIMP
COleInPlaceActiveObject::TranslateAccelerator(LPMSG pMsg
)
138 // no accelerator table, return FALSE
143 //******************************************************************************
145 // COleInPlaceActiveObject::ResizeBorder()
147 //******************************************************************************
149 STDMETHODIMP
COleInPlaceActiveObject::ResizeBorder(LPCRECT
/* lprectBorder */,
150 LPOLEINPLACEUIWINDOW
/* lpUIWindow */,
151 BOOL
/* fFrameWindow */)
156 //******************************************************************************
158 // COleInPlaceActiveObject::EnableModeless()
160 //******************************************************************************
162 STDMETHODIMP
COleInPlaceActiveObject::EnableModeless(BOOL fEnable
)
166 m_fEnableModeless = fEnable;
172 //******************************************************************************
174 // IInputObject implementation. Used by IE.
175 // Enables tabbing into the DocObject from the browser frame.
176 // Tabbing into an HTML frame with our DocObject is handled by COleObject::DoVerb().
177 // Tabbing out is via IBrowserCallbackServices::TabOut().
179 // In Firefox, tabbing in is done via IOleCommandTarget and a custom command - PHCMDID_TABINTO.
181 STDMETHODIMP
COleInPlaceActiveObject::TranslateAcceleratorIO(__in MSG
*pMsg
)
185 int nDir
= IsTabCycler(*pMsg
);
186 if(nDir
&& HasFocusIO() == S_FALSE
&& m_pOleDoc
->ApplicationHelper())
188 hr
= m_pOleDoc
->ApplicationHelper()->TabInto(nDir
> 0);
194 STDMETHODIMP
COleInPlaceActiveObject::HasFocusIO()
196 HRESULT hr
= S_FALSE
;
198 if (SUCCEEDED(GetWindow(&hwnd
)))
200 HWND hwndFocus
= GetFocus();
201 if (hwnd
== hwndFocus
|| IsChild(hwnd
, hwndFocus
))
209 STDMETHODIMP
COleInPlaceActiveObject::UIActivateIO(BOOL fActivate
, __in_opt MSG
*pMsg
)
211 // This is currently not used, but in general it should UI activate/deactivate.
212 return OnDocWindowActivate(fActivate
);